<?php
include ("../../inc/global.inc");
include("../islogin.php");
$url="index.php";
$thepage=$_GET['page']?$_GET['page']:1;
$maxpage=20;
if($_GET['del_act']){
$urls=$_SERVER['HTTP_REFERER'];
mysql_query("delete from link where id='".$_GET['del_id']."'");
echo "<script>location='".$urls."';</script>";
}
?>
<HTML>
<HEAD>
<TITLE>admin</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<LINK href="../css/css.css" rel=stylesheet>
<script type='text/javascript' src="../js/islogin.js" charset="gb2312"></script>
</HEAD>
<BODY>
<center>
  <table width="700" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <tr>
      <td height="25" bgcolor="#EEEEF9" style="padding-left:5px;">友情链接&nbsp;&nbsp;<a href="javascript:history.go(-1)">返回</a></td>
    </tr>
  </table>
<table width="700" border="0" cellspacing="0" cellpadding="0">
    <form method="post" action="<?=$url?>">
      <tr>
        <td height="50" style="line-height:22px;"><font color="blue">高级搜索：</font>链接名称
          <input name="search_name" type="text" size="25">
          &nbsp;&nbsp;&nbsp;
          <input name="submit" type="submit" value="搜索"></td>
      </tr>
      <input type="hidden" name="search_act" value="ok">
    </form>
  </table>
<?php 
if($_POST[search_act]){
$search_sql="where 1=1";
if($_POST[search_name]){
$search_sql=$search_sql." and link_name like '%$_POST[search_name]%'";
}
}
?><table width="700" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#000000" > 
	<tr align='center' bgcolor='#D8EAF4'>
	<td width="73" height="30" nowrap bgcolor="#8DA8CF" class='category'>序号</td>
	<td nowrap bgcolor="#8DA8CF" class='category'>链接名称</td>
	<td width="106" nowrap bgcolor="#8DA8CF" class='category'>是否推荐</td>
	<td width="95" nowrap bgcolor="#8DA8CF" class='category'><a href="index_modify.php?tj=ok"><font color="blue">添加链接</font></a></td>
	</tr>
<?php
$sql="SELECT * FROM link ".$search_sql." order by id desc limit ".($thepage-1)*$maxpage.",$maxpage";
$rs=mysql_query($sql);
$i=1;
while($row=mysql_fetch_array($rs)){
$color=($i%2)?"#FFFFFF":"#eeeeee";
  
  $rs2=mysql_query("select * from link_type where id='$row[type_id]'");
  $row2=mysql_fetch_array($rs2);
?>
<tr align='center' bgcolor=<?=$color?>>
<td height="20" align="center"><?=$i?></td>
<td align="left"><a href="<?=$row[link_web]?>" target="_blank">&nbsp;&nbsp;<font color="#FF6600">[<?=$row2[link_class]?>]</font>&nbsp;<?=$row[link_name]?></a></td>
<td align="center"><?php if($row[link_tj]==1){echo "<font color='red'>是</font>";}else{echo "否";}?></td>
<td align="center"><a href="index_modify.php?xg=ok&xg_id=<?=$row['id']?>">编辑</a> <a href="index.php?del_act=ok&del_id=<?=$row['id']?>" onClick="return del()">删除</a></td>
</tr>
<?php
$i++;
}
$totalrecord=mysql_num_rows(mysql_query("SELECT * FROM link ".$search_sql));
$totalpage=ceil($totalrecord/$maxpage);
?>
    <tr><form method="get" action="<?=$url?>">
       <td height="31" colspan="4" align="center" bgcolor="#FFFFFF">
	   <?php if($thepage>1){?>
	   <a href="<?=$url?>">第一页</a>&nbsp;<a href="<?=$url?>?page=<?=$thepage-1?>">上一页</a>
	   <?php }?>
	   <?php if($thepage!=$totalpage&&$totalpage>1){?>
	   <a href="<?=$url?>?page=<?=$thepage+1?>">下一页</a>&nbsp;<a href="<?=$url?>?page=<?=$totalpage?>">最后一页</a>
      <?php }?>【共<font color="red"><?=$totalrecord?></font>条记录】【每页<font color="red"><?=$maxpage?></font>条记录】【共<font color="red"><?=$totalpage?></font>页】      </td></form>
	</tr>
</table>
</center>
</BODY>
</HTML>

